package edu.cornell.cubooks.dao;

import java.util.Set;

import edu.cornell.cubooks.domain.Posting;
import edu.cornell.cubooks.domain.User;

/**
 * Data Access Object interface for postings.
 * 
 * @author CUBooks Team
 */
public interface PostingDao extends GenericDao<Posting, Integer> {

	/**
	 * Get postings for given user.
	 * @param user the user for whom the postings should be returned
	 * 
	 * @return List of Postings
	 */
	public Set<Posting> getMine(User user);
	
	/**
	 * Closes posting.
	 * 
	 * @param posting
	 */
	public Posting close(Posting posting);
	
	/**
	 * Closes all postings.
	 * 
	 * @param postings
	 * @return Set<Posting>
	 */
	public Set<Posting> closeAll(Set<Posting> postings);
	
	/**
	 * Checks if the given posting can be closed.
	 * 
	 * @param posting
	 * @return true if posting can be closed and false if not
	 */
	public boolean isClosable(Posting posting);
	
	/**
	 * Loads all postings based on given status.
	 * 
	 * @param status
	 * @return set of postings
	 */
	public Set<Posting> getAllByStatus(int status);
	
	/**
	 * Loads all postings for given user and his bids.
	 * 
	 * @param user
	 * @return set of postings
	 */
	public Set<Posting> getAllByUserBids(User user);
	
	/**
	 * Loads all postings for given posting title.
	 * 
	 * @param title
	 * @return set of postings
	 */
	public Set<Posting> getAllBySearchTitle(String title);

}
